export const columnsTitle = vm => {
  const columnsList = [
    {
      type: 'index',
      minWidth: 50,
      fixed: 'left',
      index: index => index + 1 + (vm.pagingInfo.curr_page - 1) * vm.pagingInfo.page_size,
    },
    // { type: 'selection', fixed: 'left', minWidth: 50 },
    {
      title: '入库单号/参考号',
      key: 'pm_code',
      align: 'left',
      minWidth: 300,
      render: (h, row) => {
        const { sm_code, inbound_order_no, isChildren } = row
        if (!isChildren) {
          return h('span', [
            h('div', inbound_order_no ? `入库单号：${inbound_order_no || ''}` : ''),
            h('div', sm_code ? `参考号：${sm_code}` : ''),
          ])
        }
      },
    },

    {
      title: '仓库',
      key: 'warehouse_code',
      minWidth: 200,
    },
    {
      title: 'sku / 数量',
      key: 'sku_total',
      minWidth: 200,
      render: (h, row) => {
        // sku_total sku数  - total_number 总数
        const { quantity_L, sku_L, sku, quantity, Multiple = '', isChildren } = row
        if (!isChildren) {
          if (Multiple) {
            return h(
              'span',
              {
                style: { color: '#347af4', cursor: 'pointer' },
                on: {
                  click: () => {
                    if (!row.isExpan) {
                      row.isExpan = true
                    } else {
                      row.isExpan = false
                    }
                    vm.$refs.multipleTable.toggleRowExpansion(row, row.isExpan)
                  },
                },
              },
              Multiple,
            )
          }
          const val = `${sku_L || 0} * ${quantity_L || 0}`

          return h('span', val)
        }
        return h('span', `${sku || 0} * ${quantity || 0}`)
      },
    },

    {
      title: '接收数量/总数量',
      key: 'total_packages',
      minWidth: 160,
      render: (h, row) => {
        const { receiving_package_count = 0, total_packages = 0, isChildren } = row
        if (!isChildren) {
          const val = `${receiving_package_count || 0}/${total_packages || 0}`

          return h('span', val)
        }
      },
    },

    {
      title: '已收货件数/总件数',
      key: 'sku_total',
      minWidth: 200,
      render: (h, row) => {
        // sku_total sku种类数  - total_number 总数
        const { receiving_count, total_number, isChildren } = row
        if (isChildren) return
        const val = `${receiving_count || 0} / ${total_number || 0}`

        return h('span', val)
      },
    },
    {
      title: '货柜类型',
      key: 'container_type',
      minWidth: 150,
      render: (h, row) => {
        const { container_type, isChildren } = row
        if (isChildren) return

        // 1.箱子 2.托盘栈板 3.代表20 4.代表20GP 5.代表40GP 6.代表40HQ 7.代表45GP 8.代表45HQ
        let val = ''
        switch (String(container_type)) {
          case '1':
            val = '箱子'
            break

          case '2':
            val = '托盘栈板'
            break

          case '3':
            val = '代表20'
            break

          case '4':
            val = '代表20GP'
            break

          case '5':
            val = '代表40GP'
            break

          case '6':
            val = '代表45GP'
            break

          case '7':
            val = '代表40HQ'
            break

          case '8':
            val = '代表45HQ'
            break
          default:
            break
        }
        return h('span', val)
      },
    },
    {
      title: '物流单号/柜号',
      key: 'tracking_number',
      minWidth: 250,
    },

    {
      title: '备注',
      key: 'status',
      minWidth: 150,
    },
    {
      title: '状态',
      key: 'inbound_order_status',
      minWidth: 150,
    },
    {
      title: '创建时间',
      key: 'create_time',
      minWidth: 200,
      render: (h, row) => {
        const { create_time, income_time, completion_time } = row

        return h('span', [
          h('div', create_time ? `创建时间：${create_time || ''}` : ''),
          h('div', income_time ? `送达时间：${income_time}` : ''),
          h('div', completion_time ? `完成时间：${completion_time}` : ''),
        ])
      },
    },
  ]
  return columnsList
}
